﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace WeChatParking.Core.Payment.WeixinPay
{
    /// <summary>
    ///  统一下单响应实体
    /// </summary>
    [XmlRoot(Namespace = "", IsNullable = false, ElementName = "xml")]
    public class WxpayUnifiedOrderResponse
    {

        //// <summary>
        /// 返回状态码 return_code 必填 SUCCESS/FAIL
        /// </summary> 
        [XmlElement("return_code")]
        public string ReturnCode { get; set; }

        /// <summary>
        ///返回信息  return_msg 选填 
        /// </summary>   
        [XmlElement("return_msg")]
        public string ReturnMsg { get; set; }


        //==================以下字段在return_code为success的时候有返回====================
        /// <summary>
        /// 公众账号ID  appid  必填
        /// </summary> 
        [XmlElement("appid")]
        public string AppID { get; set; }

        /// <summary>
        ///  商户号 mch_id 必填 
        /// </summary>  
        [XmlElement("mch_id")]
        public string MchID { get; set; }
        /// <summary>
        /// 设备号  device_info 选填 
        /// </summary>   
        [XmlElement("device_info")]
        public string DeviceInfo { get; set; }

        /// <summary>  
        /// 随机字符串 nonce_str 必填 
        /// </summary>
        [XmlElement("nonce_str")]
        public string NonceStr { get; set; }
        /// <summary>
        /// 签名  sign 必填 
        /// </summary>
        [XmlElement("sign")]
        public string Sign { get; set; }

        /// <summary>
        /// 业务结果  result_code 必填  SUCCESS/FAIL
        /// </summary> 
        [XmlElement("result_code")]
        public string ResultCode { get; set; }

        /// <summary>
        /// 错误代码  err_code 选填 
        /// </summary> 
        [XmlElement("err_code")]
        public string ErrCode { get; set; }

        /// <summary>
        /// 错误代码描述  err_code_des 选填
        /// </summary> 
        [XmlElement("err_code_des")]
        public string ErrCodeDes { get; set; }


        //==================以下字段在return_code和result_code为success的时候有返回====================
        /// <summary>
        /// 交易类型  trade_type 必填 JSAPI,NATIVE,APP
        /// </summary>  
        [XmlElement("trade_type")]
        public string TradeType { get; set; }

        /// <summary>
        /// 预支付ID  prepay_id 必填
        /// </summary> 
        [XmlElement("prepay_id")]
        public string PrepayID { get; set; }

        /// <summary>
        /// 二维码链接 code_url 选填
        /// </summary> 
        [XmlElement("code_url")]
        public string CodeUrl { get; set; }

        public IDictionary<string, string> GetParameters()
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("return_code", this.ReturnCode);
            parameters.Add("return_msg", this.ReturnMsg);
            parameters.Add("appid", this.AppID);
            parameters.Add("mch_id", this.MchID);
            parameters.Add("device_info", this.DeviceInfo);
            parameters.Add("nonce_str", this.NonceStr);
            parameters.Add("sign", this.Sign);

            parameters.Add("result_code", this.ResultCode);
            parameters.Add("err_code", this.ErrCode);
            parameters.Add("err_code_des", this.ErrCodeDes);
            parameters.Add("trade_type", this.TradeType);
            parameters.Add("prepay_id", this.PrepayID);
            parameters.Add("code_url", this.CodeUrl);
            return parameters;
        }

    }
}
